package com.digitalconsulting.shopaholic;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;

public class SplashScreenActivity extends Activity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		SharedPreferences sp = PreferenceManager
				.getDefaultSharedPreferences(getBaseContext());
		boolean useSplashScreen = sp.getBoolean("checkboxSplashScreen", true);

		if (useSplashScreen) {
			setContentView(R.layout.splash_screen);
			Handler handler = new Handler();
			handler.postDelayed(new Runnable() {

				public void run() {
					Intent intent = new Intent();
					intent.setClass(SplashScreenActivity.this,
							MainActivity.class);
					startActivity(intent);

					finish();
				}
			}, 3000);
		} else {
			Intent intent = new Intent();
			intent.setClass(SplashScreenActivity.this, MainActivity.class);
			startActivity(intent);

			finish();
		}
	}
}
